#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pytest
import urllib.request

def test_pa_unmixing_for_fe_test():
    req = urllib.request.Request(url='http://127.0.0.1:5000/api/system_initialization', method='PUT')
    with urllib.request.urlopen(req) as f:
        print("status: /api/system_initialization")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/pa_molecular_imaging/unmixing/7,8,9,14?for_fe_test=true', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/pa_molecular_imaging/unmixing/7,8,9,10,11,12,13,14")
        print(f.status)

def test_pa_unmixing_using_8_wavelength():
    req = urllib.request.Request(url='http://127.0.0.1:5000/api/system_initialization', method='PUT')
    with urllib.request.urlopen(req) as f:
        print("status: /api/system_initialization")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/pa_molecular_imaging/unmixing/7,8,9,14?for_fe_test=true', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/pa_molecular_imaging/unmixing/7,8,9,10,11,12,13,14")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/acquisition/7', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/acquisition/7")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=US&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=US&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/acquisition/8', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/acquisition/8")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/acquisition/9', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/acquisition/9")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/acquisition/10', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/acquisition/10")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/acquisition/11', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/acquisition/11")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/acquisition/12', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/acquisition/12")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true")
        print(f.status)


    req = urllib.request.Request(url='http://127.0.0.1:5000/api/acquisition/13', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/acquisition/13")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/acquisition/14', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/acquisition/14")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/reconstruction/Rawdata_FPGA1_Frame0.bin?modality=PA&method=DAS&log_compress_parameter=18&sound_speed=1500&generate_crop_roi=true")
        print(f.status)

    req = urllib.request.Request(url='http://127.0.0.1:5000/api/pa_molecular_imaging/unmixing/7,8,9,10,11,12,13,14?for_fe_test=false', method='GET')
    with urllib.request.urlopen(req) as f:
        print("status: /api/pa_molecular_imaging/unmixing/7,8,9,10,11,12,13,14")
        print(f.status)

if __name__ == '__main__': 
    print("API Test of pa_molecular_imaging/unmixing/.")
    test_pa_unmixing_for_fe_test()
    test_pa_unmixing_using_8_wavelength()
